(function($){
//update visitor callback handle
Drupal.Nodejs.callbacks.updateVisitorHandler = {
  callback: function (message) {
    if (message.callback == 'updateVisitorHandler') {
      $.get('/admin/livesupport/visitor/update', function(data) {
        $('#chatroom-livesupport-visitors-form').replaceWith($(data.form));
        Drupal.attachBehaviors();
      });
    }
  }
};
//update chatroom callback handle
Drupal.Nodejs.callbacks.updateChatroomHandler = {
  callback: function (message) {
    if (message.callback == 'updateChatroomHandler') {
      var cid = message.data.cid;
      if (message.data.status == 3) {
        $('#chatroom-livesupport-' + cid).remove();
        var new_elem = $('#chatroom-cid-' + cid).html();
        $('#chatroom-cid-' + cid).replaceWith('<li>' + new_elem + '</li>');
        Drupal.attachBehaviors();
      }
      if (message.data.status != 3) {
        $('#chatroom-livesupport-' + message.data.cid).removeClass('element-invisible');
        $('#chatroom-livesupport-' + cid).addClass('maximize').removeClass('minimize');
      }
    }
  }
};
})(jQuery);